// 组件外使用pinia  需要引入pinia 
import pinia from '@/stores/'
import router from '@/router/'
import { useSearchStore } from '@/stores/search'
export const useSearch = useSearchStore(pinia)
export const useSearchFn = ()=>{
    // 返回上级
    const onClickLeft = () => {
        router.push('/') 
        useSearch.showSearch = false
    }
    // 搜索
    const onSearch = (val:any) => {
        useSearch.historyList.push(val)
        useSearch.showSearch = !useSearch.showSearch
    }
    const onCancel = () => {
        useSearch.searchData = ''
    }
    const onClickSearch = () => {
        useSearch.showSearch = false
        useSearch.searchData = ''
    }
    return {onClickLeft,onSearch,onCancel,onClickSearch,useSearch}
}